class QuanLy < ActiveRecord::Base
  attr_accessible :nhan_vien_id, :phong_id, :ngay_cap_nhat
  belongs_to :phong, :class_name => "Phong", :foreign_key => "phong_id"
  belongs_to :nhanvien, :class_name => "NhanVien", :foreign_key => "nhan_vien_id"

  def self.getAllbyNV(nvid)
    ql = QuanLy.where(:nhan_vien_id => nvid)
    return ql_hash = ql.collect{ |c| {:MaPhong => c.phong.MaPhong, :Phong => c.phong.TenPhongg, :Ngay => c.ngay_cap_nhat} }
  end
  def self.getAllbyPhong(pid)
  	ql = QuanLy.where(:phong_id => pid).first()
  	return ql.nhanvien
  end
end
